// 从服务器获取各类型消息的未读数量（拆分版）
import {
  getFanUnreadNumAPI,
  getLikeUnreadNumAPI,
  getCommentUnreadNumAPI,
  getAtUnreadNumAPI
} from '@/api/notifications/notifications'

// 1. 获取粉丝相关未读数量
export async function fetchFanUnreadNum(userId) {
  const res = await getFanUnreadNumAPI(userId);
  return res.data; // 直接返回具体数值（如：3）
}

// 2. 获取点赞相关未读数量
export async function fetchLikeUnreadNum(userId) {
  const res = await getLikeUnreadNumAPI(userId);
  return res.data;
}

// 3. 获取评论相关未读数量
export async function fetchCommentUnreadNum(userId) {
  const res = await getCommentUnreadNumAPI(userId);
  return res.data;
}

// 4. 获取@我的未读数量
export async function fetchAtUnreadNum(userId) {
  const res = await getAtUnreadNumAPI(userId);
  return res.data;
}

// 保留原组合函数（内部调用拆分后的独立函数，保持代码复用）
export async function fetchAllMessageUnreadNums(userId) {
  const [
    fanUnreadNum,
    likeUnreadNum,
    commentUnreadNum,
    atUnreadNum
  ] = await Promise.all([
    fetchFanUnreadNum(userId),  // 调用独立函数
    fetchLikeUnreadNum(userId),
    fetchCommentUnreadNum(userId),
    fetchAtUnreadNum(userId)
  ]);
  return {
    fanUnreadNum,
    likeUnreadNum,
    commentUnreadNum,
    atUnreadNum
  };
}